package com.lms.common.web.utils;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

@Schema(description = "保存前的校验方法返回的校验信息")
public class CheckEntityResult {
    @Getter
    @Schema(description = "是否校验通过")
    private boolean ok;
    @Getter
    @Schema(description = "校验未通过时的返回结果")
    private final List<SingleCheckEntityResult> result;

    private CheckEntityResult() {
        ok = true;
        result = new ArrayList<>();
    }
    public static CheckEntityResult getInstance() {
        return new CheckEntityResult();
    }
    public void add(String column, String message) {
        SingleCheckEntityResult singleCheckEntityResult = SingleCheckEntityResult.builder()
                .column(column)
                .message(message)
                .build();
        this.result.add(singleCheckEntityResult);
        this.ok = false;
    }
}
